package com.zy.qudadid.presenter;


import com.zy.qudadid.model.Register;
import com.zy.qudadid.model.Res;
import com.zy.qudadid.network.Const;
import com.zy.qudadid.network.Net;
import com.zy.qudadid.presenter.base.BasePresenterImp;
import com.zy.qudadid.ui.view.RegisterCInfoView;

import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by ninos on 2016/7/30.
 */
public class RegisterCInfoPresenter extends BasePresenterImp<RegisterCInfoView> {
    public void RegisterDriver(String data) {
        Subscription subscription = Net.getService()
                .RegisterDriver(data)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<Res>() {

                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        view.exception();
                    }

                    @Override
                    public void onNext(Res res) {
                        int num = 0;
                        Register r = null;
                        if (res.code == Const.OK) {
                            view.success();
                        }else{
                            view.error(res.message);
                        }
                    }
                });

        addSubscription(subscription);
    }
}
